const int analogOutPin = 3;
 unsigned char ledLight = 0;

void setup() {  
  Serial.begin(9600);
}

void loop() {
  short int value = analogRead(A0);
  ledLight = convert_adc2light(value);
  analogWrite( analogOutPin, ledLight);
  Serial.println(ledLight);
}

short int convert_adc2temperature(short int ax)
{
   short int tempx;
   tempx = 10+(ax-593)*(60-10)/(335-593);
   return tempx;
}

short int convert_adc2light( short int value)
{
  short int result;
  result = (value - 335)*255/(593-335);
  return result;
}